home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Format 1994 October
/
Macformat17.cdr
/
Shareware City
/
Developers
/
Think C dcmd 1.0 ƒ
/
Think Put Lib source
/
PutBinary.c
< prev
next >
Wrap
Text File
|
1994-06-19
|
570b
|
34 lines
void PutChar(char c);
void PutText(const char* s, int len );
void __BinToText (unsigned long bin, char* str );
void PutBinary (unsigned long i, int nz)
{
char* str = "00000000000000000000000000000000";
int firstNz;
if ( nz > 0 && nz <= 32 )
{
firstNz = nz;
__BinToText (i, str );
PutChar( '~' );
while ( nz % 4 )
{
PutChar( str[32-nz] );
nz--;
}
if ( nz && nz != firstNz ) PutChar(',');
while ( nz ) // on entry, nz is a multiple of 4
{
PutText( &str[32-nz], 4 );
nz -= 4;
if ( nz ) PutChar(',');
}
}
}